package com.yang.webapi.module.controller;

import com.yang.service.model.vo.ProductVO;
import com.yang.webapi.module.service.ProductWebService;
import com.zhy.base.webapi.annoation.ResponseFormatter;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@ResponseFormatter
@RequestMapping(value = "product")
@CrossOrigin
@Slf4j
@Api(tags = "商品管理", description = "ProductController")
public class ProductController {

    @Autowired
    private ProductWebService productWebService;

    @ApiOperation("根据shopId获取所有商品")
    @GetMapping("list")
    public List<ProductVO> getAllProductByShopId(@RequestParam(value = "shopId") String shopId){
        return productWebService.getAllProductByShopId(shopId);
    }

    @ApiOperation("根据productId查询商品详细信息")
    @GetMapping("details")
    public ProductVO getProductDetailsByProductId(@RequestParam(value = "productId") String productId){
        return productWebService.getProductDetailsByProductId(productId);
    }
}
